﻿using Common;
using GalaSoft.MvvmLight.Threading;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace msap.Common
{
    public class WPFWaitingService : IWaitingService
    {
        static WaitingWindow window;
        static WPFWaitingService()
        {
            window = new WaitingWindow();
        }
        public void StartWaitingAsync(string msg)
        {

            DispatcherHelper.UIDispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                new Action(() =>
                {
                    window.ShowDialog(msg);
                }));
        }

        public void StopWaitingAsync()
        {

            DispatcherHelper.UIDispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                new Action(() =>
                {
                    window.Hide();
                }));
     
        }
    }
}
